package com.microptech.servicebusiness.controller;

import com.microptech.servicebusiness.service.OrderService;
import com.microptech.servicebusiness.service.RepositoryService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("business")
public class BusinessController {

    @Resource
    private OrderService orderService;

    @Resource
    private RepositoryService repositoryService;

    @GetMapping("/create")
    public String createOrder(int uid, int goodId, int amount) {
        String orderResult = orderService.create(uid, goodId, amount);
        String storageResult = repositoryService.reduce(uid, goodId, amount);
        return orderResult+"\n"+storageResult;
    }
}
